SFC flags
SFC flags are implicitly generated variables with predefined names. You can use flags to influence the processing of an SFC chart. You can use these flags, for example, to display timeouts or reset step chains. In addition, you can activate jogging mode specifically to activate transitions. You have to declare and activate these variables in order to have access to them.
SFC flags
Name | Data Type | Description |
---|---|---|
|
|
|
|
| Behaves similar to However, CODESYS continues processing after the initialization of the initial step. For example, in the initial step, you could immediately reset the |
|
|
|
|
| Used specifically for activating ( If you declare and activate this variable (SFC settings), then you must set it to The requirement is the declaration of |
|
| Stores the name of the step that caused a timeout, which was registered by The name is kept until the registered step error is reset by means of The requirement is the declaration of |
|
| Stores the name of the block in which a timeout occurred and was registered by The requirement is the declaration of |
|
| As long as this Boolean variable is The requirement is the declaration of |
|
| As long as this variable is |
|
|
|
|
| Shows the name of the active step, regardless of the time monitoring In parallel branches, the name of the step of the rightmost branch line is always stored. |
|
| Controls the "jogging mode" of the SFC block If you enable this flag with |
| Contains as string all variables that contribute to the total value
| |
| Contains in a table all variables that contribute to the total value
|
Implicit generation of SFC flags
CODESYS declares SFC flags automatically when you activate the respective options. You can set this option in the SFC Settings tab of the properties dialog for each POU, or in the SFC project settings dialog for each SFC POU in the project.
Tip
The SFC settings for the SFC flags of individual POUs are effective only if you have not selected the Use defaults option. When you select this option, the settings apply that were defined in the project settings.
Tip
SFC flags that you declare in the SFC settings dialog are visible only in the online view of the SFC block.
Explicit generation of SFC flags
Manual declaration, which was necessary in CoDeSys V2.3, is now only required to enable write access from another block. In this case, you should note that when you declare the flag in a global variable list, you must deactivate its Declare setting in the SFC settings dialog. If you do not do this, then a local SFC flag is implicitly declared which CODESYS uses instead of the global variable.
Application examples for SFCError
You have created an SFC block named sfc1
, which contains the s1
step. You have defined timeouts in the step properties. (See "Online view of sfc1
SFC POU" below.)
If for any reason the s1
step remains active longer than its time properties have permitted (timeout), then CODESYS sets the SFCError
flag to permit access by the application.
To permit access, you have to declare and activate the SFC flag in the SFC settings. If you have only declared it, then the SFC flag is only displayed in the online view of sfc1
in the declaration part, but it has no function.

Now the SFC flag can be referenced within the POU, for example in an action (2) or outside of the block (1).

Online view of the SFC block sfc1

SFCError
is TRUE
as soon as a timeout occurs within sfc2
.
Note that you can use the SFCErrorAnalyzation
and SFCErrorAnalyzationTable
flags (Analyzation
library) to determine the components of the expression that contributes to the value TRUE
of the SFCError
.
Access to the flags
Syntax for access
You assign the flag directly within the POU: <variable name>:=<SFC flag>
checkerror:=SFCerror;
From another POU with POU name: <variable name>:=<POU name>.<SFC flag>
checkerror:=SFC_prog.SFCerror;
If you need write access from another block, then you also have to declare the SFC flag explicitly as a VAR_INPUT variable in the SFC block or globally in a GVL.
Local declaration
PROGRAM SFC_prog VAR_INPUT SFCinit:BOOL; END_VAR
Global declaration in a global variable list
VAR_GLOBAL SFCinit:BOOL; END_VAR
PROGRAM PLC_PRG VAR setinit: BOOL; END_VAR SFC_prog.SFCinit:=setinit; //Write access to SFCinit in SFC_prog